import {Component, ElementRef, Inject, OnInit, Renderer2, ViewChild} from '@angular/core';
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
import {_HttpClient} from '@delon/theme';
import {DeliveryModule} from '../../../../service/delivent/deliveryModule';
import {UtilityService} from '../../../../service/utils.service';
import {appConfig} from '../../../../service/common';
import {NzModalService, NzNotificationService} from 'ng-zorro-antd';
import {Router} from '@angular/router';
import {DA_SERVICE_TOKEN, ITokenService} from '@delon/auth';
import {SprofilesModule} from '../../../../service/delivent/sprofilesModule';
import {BranchModule} from '../../../../service/delivent/brachModule';
import {Observable, Observer} from 'rxjs';
import * as moment from 'moment';
import * as _ from 'lodash';

@Component({
    selector: 'app-s-profiles',
    templateUrl: './s-profiles.component.html',
})
export class SProfilesComponent implements OnInit {
    constructor(
        private http: _HttpClient,
        private router: Router,
        private utilityService: UtilityService,
        private modal: NzModalService,
        private nznot: NzNotificationService,
        private fb: FormBuilder,
        @Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService,
        private confirmServ: NzModalService,
        private renderer: Renderer2
    ) {

     }

     // 变量
    token: any;
    profiles: SprofilesModule = new SprofilesModule();
    showAdd: boolean; // 是否有修改
    isShowTotal = true;
    configTitle = '详情'
    modalVisible = false;
    mergeVisible = false; // 合并投放弹窗
    isPagination = true; // 是否有分页
    isCorrelation = false;
     isCancel = false;
     assVisible = false;
     listloading = false;
     loading = false;
    // 信息
    deliverItem: DeliveryModule = new  DeliveryModule();
    deliveryTime: any; // 投放日期
    elementScice: any[] = [];
    dliveryResult = [
        {key: '0', value: '否'},
        {key: '1', value: '是'}
    ]
    data: any[] = []; // 表格数据
    headerDate = [  // 配置表头内容
        // { value: '环境代码', key: 'profilesCode', isclick: true},
        { label: '环境名称', value: 'profilesName', isclick: true},
        { label: '流水标志', value: 'serialTag', isclick: false },
        { label: 'Release分支', value: 'fullPathstr', isclick: false,title:true },
        // { value: '主机IP', key: 'hostIp', isclick: false },
        // { value: '安装路径', key: 'installPath', isclick: false },
        { label: '延期标志', value: 'isRepealstr', isclick: false, switch:false },
        { label: '开启/关闭环境', value: 'isAllowDelivery', isclick: false,  switch:true},
        { label: '环境管理人员', value: 'manager', isclick: false, switch:false },
        { label: '打包窗口', value: 'itemLablesProfile', isclick: false , switch:false},
    ];

    // 传入按钮层
    moreData = {
        morebutton: true,
        buttonData: [
            { key: 'Overview', value: '查看概况' }
        ]
    }
    buttons = [
        {key: 'add', value: '新增', if: true},
    ]
expandForm = false;
    test: string;
    page = 1;
    total: number;
    pageTotal: number;
    branshList = [];
    branch: any;
    Ptitle: any;
    time = new Date();
    tags = [];
    inputVisible = false;
    inputValue = '';
    // 管理分支
    active = true;
    isShowDetail = false;
    branchDetali = [

    ]
    isShowIp = false;
    isShowartf = false;
    // 表格数据按钮
    buttonData = [
        {key: 'rundelay', value: '运行延期'},
        {key: 'dels', value: '删除' },
        {key: 'upd', value: '修改'},
        {key: 'correlation', value: '关联分支'},
    ];
    buttonDataBranch = [
        {key: 'rundelay', value: '运行延期'},
        {key: 'dels', value: '删除' },
        {key: 'upd', value: '修改'},
        {key: 'detail', value: '取消分支'},
        {key: 'branchDDetail', value: '分支详情'},
        {key: 'project', value: '拉工程'},
        {key: 'codeDown', value: '代码下载'},

    ]
    branchType = [
        {key: 'feature', value: 'F',selector:false},
        {key: 'hot', value: 'H' ,selector:false},
    ]
    addBranch = {
        fullPath: '',
        branchFor: ''
    };
    tabs = [
        {
            active: true,
            name  : '选择已有分支',

        },
        {
            active: false,
            name  : '新增分支',

        }
    ];
    search = {
        profilesName: '',
        manager: '',
        isAllowDelivery: ''
    };
    pageIndex=1;
    @ViewChild('input') private input: ElementRef;
    ngOnInit() {
        this.token  = this.tokenService.get().seniortoken;
        this.getData();
        this.showAdd = true;

    }

       handleClose(removedTag: any): void {
           this.tags = this.tags.filter(tag => tag !== removedTag);
       }
       sliceTagName(tag: string): string {
            const isLongTag = tag.length > 20;
            return isLongTag ? `${tag.slice(0, 20)}...` : tag;
       }

       showInput(): void {
                this.inputVisible = true;
                setTimeout(() => {
                    this.input.nativeElement.focus();
                }, 10);
            }

       handleInputConfirm(): void {
                if (this.inputValue) {
                    this.tags.push({isOpen:'true',time:this.inputValue});
                }
                this.inputValue = '';
                this.inputVisible = false;
            }
            tagClick(it){

                if(it.isOpen === 'true'){
                       it.isOpen = 'false'
                }else{
                     it.isOpen = 'true'
                }
                console.log(this.tags)

            }

       reset() {
                 this.search = {
                        profilesName: '',
                        manager: '',
                        isAllowDelivery: ''
                    };
                    this.getData('search');
                }
       tabChange(obj) {
               this.active = obj;
            }
       btnLoading = false;
       submitForm() {
                let objarr = [];
                if (this.tags.length === 0) {
                      this.nznot.create('error', '请添加打包窗口', '');
                      return;
        }
        if(this.isShowIp == true){
               this.nznot.create('error', '请检查IP地址格式是否正确！', '');
              return;
        }
         if(this.isShowprofilesName || this.isShowinstallPath){
               this.nznot.create('error', '请检查信息输入是否合法！', '');
              return;
        }
          if(this.isShowserialTag == true){
               this.nznot.create('error', '请检查流水标志格式是否正确！', '');
              return;
        }
          if(!this.profiles.artf || !this.profiles.profilesName || !this.profiles.installPath || !this.profiles.hostIp || !this.profiles.csvUser || !this.profiles.manager){
               this.nznot.create('error', '请检查信息是否完整！', '');
              return;
          }


        this.profiles.packTiming = JSON.stringify(this.tags)
        this.btnLoading = true;
        if ( ! this.profiles.guid ) {
            // this.profiles.isAllowDelivery = ' ';
            this.utilityService.postData(appConfig.testUrl  + appConfig.API.sProfilesadd, this.profiles )
                .subscribe(
                    (val) => {
                         this.btnLoading = false;

                        if (val.code === '200') {
                            this.workId = val.result.guid
                             this.mergeVisible = false;
                                this.modal.open({
                                title: '信息提示',
                                content: val.msg + '是否需要立即关联分支？',
                                okText: '确定',
                                cancelText: '取消',
                                onOk: () => {
                                    this.isCorrelation = true;
                                },
                                onCancel: () => {

                                }
                            });

                            this.nznot.create('success', val.msg, val.msg);
                        }else {
                            this.nznot.create('error', val.msg, val.msg);
                        }
                    }  ,
                (error) => {
                      this.btnLoading = false;
                  this.nznot.create('error', error.code,  error.msg);
                }
                    );
                     this.getData();
        }else {
            this.utilityService.putData(appConfig.testUrl  + appConfig.API.sProfilesadd, this.profiles )
                .subscribe(
                    (val) => {
                          this.btnLoading = false;
                        this.getData();
                        if (val.code === '200') {

                            this.mergeVisible = false;
                            this.nznot.create('success', val.msg, val.msg);
                        }else {
                            this.nznot.create('error', val.msg, val.msg);
                        }
                    } ,
                (error)=>{
                      this.btnLoading = false;
                  this.nznot.create('error', error.code,  error.msg);
                }

                );
        }





    }

       checkIp(ip) {
              let MOBILE_REGEXP =/^(?:(?:1[0-9][0-9]\.)|(?:2[0-4][0-9]\.)|(?:25[0-5]\.)|(?:[1-9][0-9]\.)|(?:[0-9]\.)){3}(?:(?:1[0-9][0-9])|(?:2[0-4][0-9])|(?:25[0-5])|(?:[1-9][0-9])|(?:[0-9]))$/;
              if (MOBILE_REGEXP.test(ip) === true) {
                      this.isShowIp = false;
              }else {
                  this.isShowIp = true;
              }
            }
            isShowserialTag = false;
            checkserialTag(serialTag){
                let MOBILE_REGEXP = /^([a-z]|[A-Z]|[0-9]){1}$/;;
                            if (MOBILE_REGEXP.test(serialTag) === true) {
                                    this.isShowserialTag = false;
                            }else {
                                this.isShowserialTag = true;
                            }
                   }
       checkArtf(event){
              let MOBILE_REGEXP =/^\+?[1-9][0-9]*$/;
              if(MOBILE_REGEXP.test(event) === true){
                      this.isShowartf = false
              }else{
                  this.isShowartf = true;
              }
            }
       checkBranch(branch) {
             this.isShowDetail = true
               this.utilityService.getData(appConfig.testUrl  + appConfig.API.sBranchadd + '/' + branch)
                .subscribe(
                    (val) => {
                        if (val.code === '200') {
                            this.branchDetali = val.result;
                        }else {
                            this.nznot.create('error', val.msg , val.msg);
                        }
                    }  ,
                (error) => {
                  this.nznot.create('error', error.code,  error.msg);
                }
                );
        }
isCaocuo = true;
    getData(type?) {
           if  (type === 'search') {
              this.pageIndex = 1;
           }
        const page = {
             condition: this.search,
            page: {
                size: 10,
                current: this.pageIndex
            }
        };
       this.listloading=true;
        this.utilityService.postData(appConfig.testUrl  + appConfig.API.allsProfiles, page )
            .subscribe(
                (val) => {
                      this.listloading=false;
                    if (val.code === '200') {
                        this.data = val.result.records;
                        this.total = val.result.total; // 总数
                        this.pageTotal = val.result.pages * 10; // 页码

                        for ( let i = 0; i < this.data.length; i++) {
                            this.data[i].itemLablesProfile = JSON.parse(this.data[i].packTiming)
                           

                            this.data[i].itemName = this.data[i].fullPath;
                             this.data[i].fullPathstr = this.data[i].fullPath;
                             let flage = '运行延期';
                              if( this.data[i].isRepeal === 'true'){
                             flage = '关闭延期'
                                this.data[i]['isRepealstr'] = '已运行'
                            }else{
                                 this.data[i]['isRepealstr'] = '已关闭'
                            }
                            if (this.data[i].fullPath.length > 60) {
                              this.data[i].fullPathstr = appConfig.subString(this.data[i].fullPath, 20)
                                }
                                   if (this.tokenService.get().role === '开发组') {
                                       this.isCaocuo = false;
                                       this.data[i]['isDisabled']=true;

                                   }else{
                                        this.data[i]['isDisabled']=false;
                                        if (this.data[i].fullPath === '') {
                                  this.data[i].buttonData = [
                                                    {key: 'rundelay', value: flage},        
                                                    {key: 'dels', value: '删除' },
                                                    {key: 'upd', value: '修改'},
                                                    {key: 'correlation', value: '关联分支'},
                                                ];
                                    }else {
                                    this.data[i].buttonData = [
                                                    {key: 'rundelay', value: flage},                
                                                    {key: 'dels', value: '删除' },
                                                    {key: 'upd', value: '修改'},
                                                    {key: 'detail', value: '取消分支'},
                                                    {key: 'branchDDetail', value: '分支详情'},
                                                    {key: 'project', value: '拉工程'},

                                                ];
                                } 
                                   }
                          
                          
                            if (this.data[i].isAllowDelivery === '1') {
                                this.data[i].isAllowDelivery = true;

                            }else {
                                this.data[i].isAllowDelivery = false;
                                this.data[i].itemLablesProfile.forEach(k=>{
                                    k.isOpen = false
                                })
                            }

                        }

                    }
                    // 拼接
                }, (error) => {
                     this.listloading=false;
                      this.nznot.create('error', error.code, error.msg);
                }
            );
    }



    // 列表组件传过来的内容
    addHandler(event) {
        if (event === 'add') {
            this.profiles = new SprofilesModule();
            this.Ptitle = '新增运行环境';
            this.isShowIp = false;
            this.isShowartf = false;
              this.isShowserialTag= false
            this.tags = [];
            this.mergeVisible = true;
        } else if (event === 'checking') {
            this.modalVisible = true; // 打开核对弹出框

        } else if (event === 'export') {
            this.isVisible = true;
        } else if (event === 'ces') {
            this.isCancel = true;
        }
    }



    // 接受子组件删除的数据 单条还是多条
    deleatData(event) {

    }


    profilesGuid: any;
    branchInfo = false; // 弹出框 默认为false
    branchData: BranchModule = new BranchModule();
    branchdataInfo: boolean; // 分支详情
    projectInfo = false;
    prolist: any[] = []; // 工程列表
    filterOption(inputValue, option) {
    return option.description.indexOf(inputValue) > -1;
  }

      searchpro(ret: any) {
      }

      select(ret: any) {
      }
      subPro = []
      change(ret: any) {
         for (let i = 0 ; i < ret.list.length; i++) {
             ret.list[i]['status'] =  ret.to;
         }
      }

        list = [];

    workId: string; // 工作项ID
    // 按钮点击事件
    buttonEvent(event) {
        this.profilesGuid = event.guid
        if (event.names.key === 'dels') { // 按钮传入删除方法
            let self = this;
            this.confirmServ.confirm({
                title  : '您是否确认要删除这项内容!',
                showConfirmLoading: true,
                onOk() {
                    self.utilityService.deleatData(appConfig.testUrl  + appConfig.API.delSprofiles + self.profilesGuid)
                        .subscribe(
                            (val) => {
                                if (val.code === '200') {
                                     if ( !(( self.total - 1) % 10)) {
                                        self.pageTotal = self.pageTotal - 10 ;
                                        self.getData();
                                    }
                                    self.getData();
                                    self.nznot.create('success', val.msg, val.msg);
                                }else {
                                    self.nznot.create('error', val.msg, '');
                                }
                            }   ,
                            (error) => {
                                 self.nznot.create('error', error.msg, '');

                            }
                        );
                },
                onCancel() {
                }
            });


        } else if(event.names.key === 'project') {
                   this.utilityService.getData(appConfig.testUrl  + appConfig.API.sProfilesadd + '/' +  event.guid + '/project')
                            .subscribe(
                                (val) => {
                               let others = [];
                               let own = []
                                   if (val.result.others.length > 0){
                                        for (let  j = 0; j < val.result.others.length; j++) {
                                          val.result.others[j]['exit'] = 'left';
                                   }
                                }
                                    if (val.result.own.length > 0) {
                                       for (let j = 0; j < val.result.own.length; j++) {
                                              val.result.own[j]['exit'] = 'right';
                                       }
                                    }
                                    others = val.result.others;
                                    own = val.result.own;
                                      if(own.length > 0 && others.length > 0) {
                                           others = others.concat(own)
                                    }else if(others.length === 0 && own.length > 0 ) {
                                         others = own;
                                    }
                               const ret = [];
                                for (let i = 0; i < others.length; i++) {
                                ret.push({
                                    key: i.toString(),
                                    title: others[i]['projectName'],
                                    guid: others[i]['guid'],
                                    status: others[i]['exit'],
                                    description: others[i]['projectName'],
                                    direction: others[i]['exit'] === 'left' ? 'left' : 'right',
                                    disabled: others[i]['exit'] === 'right'
                                });
                                }
                                this.list = ret;
                                this.projectInfo = true
                                },
                                (error) => {
                                    this.nznot.create('error', error.code , error.msg);
                                }
                            );

            } else if (event.names.key === 'upd') {
            this.Ptitle = '修改运行环境'
            this.isShowartf = false;
            this.isShowserialTag = false;
            let arr = [];
            event.checkOptionsOne =  this.profiles.checkOptionsOne;
            this.profiles =  _.cloneDeep(event);
            this.tags = event.itemLablesProfile;
            this.mergeVisible = true;
        } else if (event.names.key === 'codeDown') {
            this.listloading=true;
            this.utilityService.getData(appConfig.testUrl  + appConfig.API.delSprofiles + event.guid + '/checkoutCode')
                .subscribe(
                    (val) => {
                        this.listloading =  false;
                        this.nznot.create('success', val.code,  val.msg);
                    } ,
                    (error) => {
                        this.listloading =  false;
                        this.nznot.create('error', error.code,  error.msg);
                    }
                );
        } else if (event.names.key === 'correlation') {
            this.addBranch.branchFor = '';
            this.addBranch.fullPath = ''
            this.Ptitle = '关联分支'
            this.utilityService.getData(appConfig.testUrl  + appConfig.API.getBranch)

                .subscribe(
                    (val) => {
                        if (val.code === '200') {
                            this.branshList = val.result
                            this.isShowDetail = false;
                            this.isCorrelation = true;
                            this.Ptitle = '关联Release分支'


                        }else {
                            this.nznot.create('error', val.msg, val.msg);
                        }
                    }  ,
                (error) => {
                  this.nznot.create('error', error.code,  error.msg);
                }
                );


        } else if (event.names.key  === 'branchDDetail') {
           let url= '/' + event.guid + '/branchDetail'
                this.utilityService.getData(appConfig.testUrl  + appConfig.API.sProfilesadd + url)
                    .subscribe(
                        (val) => {
                             this.branchInfo = true;
                             this.branchData = val.result;
                             this.branchData.createTime = moment(this.branchData.createTime).format('YYYY-MM-DD');
                        },
                        (error) => {
                          this.nznot.create('error', error.code,  error.msg);
                        });
            }    else if (event.names.key  === 'detail') {


            let self = this;
            this.confirmServ.confirm({
                title  : '您是否确认要取消关联分支!',
                showConfirmLoading: true,
                onOk() {
                    self.saveCorrelation('Q');
                },
                onCancel() {
                }
            });
        }else if (event.names.key === 'close') {
               this.ispackTiming = true;
               let arr=[]
              arr = event.packTiming.split(",");
                arr.forEach(element => {
                    this.packTiming.push({time:element,title:'开启'})
                });


            
            }else if(event.names.key === 'rundelay'){ 
                 let flage = 'true'
                 if(event.isRepeal === 'true'){
                         flage = 'false'
                 }
                 console.log(flage)
                   console.log(event.isRepeal)
                     let obj = {
                         guid:this.profilesGuid,
                         repeal:flage
                     }
                this.utilityService.postData(appConfig.testUrl  + '/sProfiles/updateRepeal', obj )
            .subscribe(
                (val) => {
                      this.nznot.create('success', val.code,  val.msg);
                      this.getData();
                       },(error)=>{
                        this.nznot.create('error', error.code,  error.msg);
                        })   
                  
            }

    }

  packTiming:any[]=[]

    subProject() {
    let projectGuids = []
    for (let i = 0 ; i < this.list.length; i ++) {
            if (this.list[i].status === 'right' && this.list[i].disabled === false) {
            projectGuids.push(this.list[i].guid);
        }
    }
   this.btnLoading = true;
          this.utilityService.postData(appConfig.testUrl  + appConfig.API.sProfilesadd + '/' + this.profilesGuid + '/project' ,{projectGuids:projectGuids} )
                            .subscribe(
                                (val) => {
                                     this.btnLoading = false;
                                    this.projectInfo = false;
                                    this.nznot.create('success', val.msg , val.msg);
                                    this.getData();
                                } ,
                            (error) => {
                                 this.btnLoading = false;
                                 this.nznot.create('error', error.code,  error.msg);

                            }
                            );
}
    // 关联分支方法
    saveCorrelation(item) {
        let url = ''
        if (item === 'C') {
            if (this.active === false){ // 选择新增分支
                    let id = ''
            if (this.addBranch.branchFor === '' || this.addBranch.fullPath === '') {
                 this.nznot.create('error', '请输入完整分支信息', '');
                 return;
            }
             if (this.workId) {
                 id = this.workId;
             }else {
                  id = this.profilesGuid;
             }
             this.btnLoading = true;
           this.utilityService.postData(appConfig.testUrl  + appConfig.API.sProfilesadd + '/' + id + '/branch',  this.addBranch )
            .subscribe(
                (val) => {
                    this.getData();
                      this.btnLoading = false;
                     this.isCorrelation = false;
                    this.nznot.create('success', val.msg, val.msg);
                },
                error => {
                     this.btnLoading = false;
                      this.nznot.create('error', error.code,  error.msg);
                    }
            );
        }else {
            if (this.branch == null) {
             this.nznot.create('error', '请输入完整分支信息', '');
                return;
            }
                 url = '/' + this.profilesGuid + '/branch/' + this.branch;
                  this.btnLoading = true;
                 this.utilityService.getData(appConfig.testUrl  + appConfig.API.sProfilesadd + url)
            .subscribe(
                (val) => {
                     this.btnLoading = false;
                    if (val.code === '200') {
                        this.getData()
                        this.nznot.create('success', val.msg, val.msg);
                        this.branch = null; // 清空
                        this.isCorrelation = false;
                    }else {
                        this.nznot.create('error', val.msg, '');
                    }
                }  ,
                (error) => {
                      this.btnLoading = false;
                  this.nznot.create('error', error.code,  error.msg);
                }
            );
            }
        }else {
            url = '/' + this.profilesGuid + '/cancel';
              this.btnLoading = true;
               this.utilityService.getData(appConfig.testUrl  + appConfig.API.sProfilesadd + url)
            .subscribe(
                (val) => {
                      this.btnLoading = false;
                    if (val.code === '200') {
                        this.getData()
                        this.nznot.create('success', val.msg, val.msg);
                        this.branch = null; // 清空
                        this.isCorrelation = false;
                    }else {
                        this.nznot.create('error', val.msg, '');
                    }
                }  ,
                (error) => {
                     this.btnLoading = false;
                  this.nznot.create('error', error.code,  error.msg);
                }
            );

        }
            this.branch = '';
    }

    // 列表按钮方法
    buttonDataHandler(event) {
    }
    getStatus(event) {
        event.switch = true
        let status = '';
        if (event.status === true) {
            status = '1';
        }else{
            status = '0';
        }
        let obj = {
            guid: event.guid,
            isAllowDelivery: status
        }
        this.utilityService.putData(appConfig.testUrl  + appConfig.API.getStatus, obj )
            .subscribe(
                (val) => {
                     event.switch = false
                        this.getData()
                        event.isAllowDelivery = event.status

                    if (val.code === '200') {
                        this.nznot.create('success', val.msg, val.msg);
                    }else {
                        // event.isAllowDelivery = true
                        this.nznot.create('error', val.msg, '');
                    }
                }   ,
                (error) => {
                 this.nznot.create('error', error.code,  error.msg);
                     event.switch = false;

                }
            );


    }

isShowprofilesName = false;
isShowinstallPath = false;
   checkString(event,it){

        var regs=/['\,]+/g;

       if(regs.test(event)){

         switch(it){
             case 1:
             this.isShowprofilesName = true;
             break;
              case 2:
             this.isShowinstallPath = true;
             break;


         }

      }else{

            switch(it){
             case 1:
             this.isShowprofilesName = false;
             break;
              case 2:
             this.isShowinstallPath = false;
             break;


         }
      }
      console.log(it)



    }

    // 处理行为代码，跳转、弹出框、其他交互
    isActive(event) {
         this.router.navigate(['profilesView'],
            { queryParams:
                    { guid: event.guid
                    }
            });
    }


    selectedRow(event) { // 选中方法，折叠层按钮显示方法

    }


    // 搜索框
    // search() {

    // }


    // 比对界面
    checkVisible = false; // 默认是关闭的



    // 核对清单弹框
    environment = [
        { text: 'SIT', value: false, key: 'SIT' },
        { text: 'SIT Dev', value: false, key: 'Dev' },
        { text: 'UAT', value: false, key: 'UAT' }
    ]


    save() {
        this.modalVisible = false; // 关闭选择框
        this.checkVisible = true; // 打开核对弹出框
    }
  ispackTiming = false;
   getPackTiming(){

   }


    // 状态
    returns() {

    }

    sussess() {

    }

    errors() {

    }

    // 列表传入的翻页数据
    monitorHandler(event) {
        this.pageIndex = event;
          this.getData();
    }
    // 关闭核对清单
    checkSave() {
        this.checkVisible = false;
    }

    // 打印界面
    isVisible = false; // 默认关闭
    workItem = false;
    handleOk() {
        // 请求数据 下载下来
        this.isVisible = false; // 关闭弹出框
    }

    // 合并的确定
    determine() {
        this.mergeVisible = false;
    }



}
